from django.db import models


# Create your models here.
class Device(models.Model):
    """
    设备表字段
    """

    class Meta:
        db_table = 'DEVICE'

    # id
    id = models.IntegerField(primary_key=True)
    # 设备code
    code = models.CharField(max_length=64)
    # 设备名称
    name = models.CharField(max_length=64)
    # 序列号 设备全系统唯一
    sn = models.CharField(max_length=32)
    # 设备类型码
    tp_code = models.CharField(max_length=255)
    # 设备签名密钥
    secret_key = models.CharField(max_length=64)
    # 在线状态[online：在线、 offline：下线]
    online_state = models.CharField(max_length=32)
    # 最近上下线时间
    online_state_time = models.DateTimeField()
    # 激活状态[active：未激活、inactive：已激活]
    activation_state = models.CharField(max_length=32)
    # 激活状态调整时间
    activation_state_time = models.DateTimeField()
    # 分享最大个数限制
    share_max_num = models.IntegerField()
    # mac地址
    mac = models.CharField(max_length=64)
    # 图标URL
    icon_url = models.CharField(max_length=256)
    # 硬件平台
    hardware_platform = models.CharField(max_length=32)
    # 数据中心
    data_center = models.CharField(max_length=1024)
    # 三方云平台编号
    cloud_platform_code = models.CharField(max_length=32)
    # 版本号
    version_no = models.CharField(max_length=64)
    # 批次ID
    batch_id = models.IntegerField()
    # 设备所属产品
    product_id = models.IntegerField()
    # 机构ID
    org_id = models.IntegerField()
    # 能力集
    power_set = models.CharField(max_length=3000)
    # 删除标识[0：未删处、1：已删除]
    del_flag = models.IntegerField()
    # 创建人
    creator = models.CharField(max_length=32)
    # 修改人
    modifier = models.CharField(max_length=32)
    # 创建时间
    created = models.DateTimeField()
    # 修改时间
    modified = models.DateTimeField()
    # 异常信息
    exception_info = models.CharField(max_length=100)

    def all(self):
        return ["id", "code", "name", "sn", "tp_code", "secret_key", "online_state", "online_state_time",
                "activation_state", "activation_state_time", "share_max_num", "mac", "icon_url", "hardware_platform",
                "data_center", "cloud_platform_code", "version_no", "batch_id", "product_id", "org_id", "power_set",
                "del_flag", "creator", "modifier", "created", "modified", "exception_info"]
